package co.yixiang.modules.shop.service.impl;

import co.yixiang.common.service.impl.BaseServiceImpl;
import co.yixiang.modules.shop.entity.YxInvestIncome;
import co.yixiang.modules.shop.mapper.YxInvestIncomeMapper;
import co.yixiang.modules.shop.mapping.YxInvestIncomeMap;
import co.yixiang.modules.shop.service.YxInvestIncomeService;
import co.yixiang.modules.shop.web.param.YxInvestIncomeQueryParam;
import co.yixiang.modules.shop.web.vo.YxInvestIncomeQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author frq
 * @date 2020-06-09
 */
@Slf4j
@Service
    @Transactional(rollbackFor = Exception.class)
    public class YxInvestIncomeServiceImpl extends BaseServiceImpl<YxInvestIncomeMapper,YxInvestIncome> implements YxInvestIncomeService {

        @Autowired
        private YxInvestIncomeMapper yxInvestIncomeMapper;
        @Autowired
        private YxInvestIncomeMap yxInvestIncomeMap;
    @Override
    public List<YxInvestIncomeQueryVo> getList(YxInvestIncomeQueryParam yxInvestIncomeQueryParam) {
        QueryWrapper<YxInvestIncome> wrapper=new QueryWrapper<>();
        wrapper.orderByDesc("income_total");

        Page<YxInvestIncome> pageModel = new Page<>(yxInvestIncomeQueryParam.getPage(), yxInvestIncomeQueryParam.getLimit());
        IPage<YxInvestIncome> iPage=yxInvestIncomeMapper.selectPage(pageModel,wrapper);
        return yxInvestIncomeMap.toDto(iPage.getRecords());
    }
}
